import 'package:flutter/material.dart';
import 'dart:math' as math;

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: _title,
        home: Scaffold(
          appBar: AppBar(
            title: Text("1111"),
          ),
          body: MyHome(),
        ));
  }
}

class MyHome extends StatelessWidget {
  const MyHome({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(children: [
      Container(
        height: 150,
        child: UnconstrainedBox(
          child: Container(
            color: Colors.black,
            child: Transform(
                alignment: Alignment.topRight, //相对于坐标系原点的对齐方式
                transform: Matrix4.skewY(0.3), //沿Y轴倾斜0.3弧度
                child: Container(
                  // height: 50,
                  // width: 100,
                  padding: const EdgeInsets.all(8.0),
                  color: Colors.deepOrange,
                  child: const Text('Apartment for rent!'),
                )),
          ),
        ),
      ),
      Container(
        height: 20,
        child: UnconstrainedBox(
          child: Container(
              color: Colors.black,
              child: DecoratedBox(
                decoration: BoxDecoration(color: Colors.red),
                //默认原点为左上角，左移20像素，向上平移5像素
                child: Transform.translate(
                  offset: Offset(-20.0, 5.0),
                  child: Text("Hello world"),
                ),
              )),
        ),
      ),
      Container(
        height: 100,
        child: UnconstrainedBox(
          child: Container(
              color: Colors.black,
              child: DecoratedBox(
                decoration: BoxDecoration(color: Colors.red),
                //旋转 90°
                child: Transform.rotate(
                  angle: math.pi / 2,
                  child: Text("Hello world"),
                ),
              )),
        ),
      ),
      Container(
        height: 100,
        child: UnconstrainedBox(
          child: Container(
              color: Colors.black,
              child: DecoratedBox(
                decoration: BoxDecoration(color: Colors.red),
                // 缩放
                child: Transform.scale(
                  scale: 1.5,
                  child: Text("Hello world"),
                ),
              )),
        ),
      ),
      Padding(
        padding: const EdgeInsets.symmetric(horizontal: 20),
        child: Container(
          height: 100,
          width: 150,
          child: Transform.rotate(
            angle: math.pi / 10,
            child: Container(
              decoration: BoxDecoration(
                  gradient: RadialGradient(colors: [Color(0xFFD21717), Color(0xFFCD800D)], center: AlignmentDirectional.topStart, radius: .98),
                  boxShadow: [BoxShadow(color: Colors.black38, offset: Offset(5, 5), blurRadius: 5)]),
              alignment: AlignmentDirectional.center,
              child: Text("5.20", style: TextStyle(color: Colors.white, fontSize: 20)),
            ),
          ),
        ),
      ),
    ]);
  }
}
